<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/gui/dialogs/qinputdialog.cpp -->
<head>
  <title>Qt 4.3: QInputDialog Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QInputDialog Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1>
<p>The QInputDialog class provides a simple convenience dialog to get a single value from the user. <a href="#details">More...</a></p>
<pre> #include &lt;QInputDialog&gt;</pre><p>Inherits <a href="qdialog.html">QDialog</a>.</p>
<ul>
<li><a href="qinputdialog-members.html">List of all members, including inherited members</a></li>
<li><a href="qinputdialog-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"/>double <b><a href="qinputdialog.html#getDouble">getDouble</a></b> ( QWidget * <i>parent</i>, const QString &amp; <i>title</i>, const QString &amp; <i>label</i>, double <i>value</i> = 0, double <i>minValue</i> = -2147483647, double <i>maxValue</i> = 2147483647, int <i>decimals</i> = 1, bool * <i>ok</i> = 0, Qt::WindowFlags <i>f</i> = 0 )</li>
<li><div class="fn"/>int <b><a href="qinputdialog.html#getInteger">getInteger</a></b> ( QWidget * <i>parent</i>, const QString &amp; <i>title</i>, const QString &amp; <i>label</i>, int <i>value</i> = 0, int <i>minValue</i> = -2147483647, int <i>maxValue</i> = 2147483647, int <i>step</i> = 1, bool * <i>ok</i> = 0, Qt::WindowFlags <i>f</i> = 0 )</li>
<li><div class="fn"/>QString <b><a href="qinputdialog.html#getItem">getItem</a></b> ( QWidget * <i>parent</i>, const QString &amp; <i>title</i>, const QString &amp; <i>label</i>, const QStringList &amp; <i>list</i>, int <i>current</i> = 0, bool <i>editable</i> = true, bool * <i>ok</i> = 0, Qt::WindowFlags <i>f</i> = 0 )</li>
<li><div class="fn"/>QString <b><a href="qinputdialog.html#getText">getText</a></b> ( QWidget * <i>parent</i>, const QString &amp; <i>title</i>, const QString &amp; <i>label</i>, QLineEdit::EchoMode <i>mode</i> = QLineEdit::Normal, const QString &amp; <i>text</i> = QString(), bool * <i>ok</i> = 0, Qt::WindowFlags <i>f</i> = 0 )</li>
</ul>
<ul>
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>2 properties inherited from <a href="qdialog.html#properties">QDialog</a></li>
<li><div class="fn"/>56 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li><div class="fn"/>5 public functions inherited from <a href="qdialog.html#public-functions">QDialog</a></li>
<li><div class="fn"/>201 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
<li><div class="fn"/>12 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
<li><div class="fn"/>4 public slots inherited from <a href="qdialog.html#public-slots">QDialog</a></li>
<li><div class="fn"/>19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li><div class="fn"/>3 signals inherited from <a href="qdialog.html#signals">QDialog</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
<li><div class="fn"/>38 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li><div class="fn"/>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
<li><div class="fn"/>1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QInputDialog class provides a simple convenience dialog to get a single value from the user.</p>
<p>The input value can be a string, a number or an item from a list. A label must be set to tell the user what they should enter.</p>
<p>Four static convenience functions are provided: <a href="qinputdialog.html#getText">getText</a>(), <a href="qinputdialog.html#getInteger">getInteger</a>(), <a href="qinputdialog.html#getDouble">getDouble</a>() and <a href="qinputdialog.html#getItem">getItem</a>(). All the functions can be used in a similar way, for example:</p>
<pre>     bool ok;
     QString text = QInputDialog::getText(this, tr(&quot;QInputDialog::getText()&quot;),
                                          tr(&quot;User name:&quot;), QLineEdit::Normal,
                                          QDir::home().dirName(), &amp;ok);
     if (ok &amp;&amp; !text.isEmpty())
         textLabel-&gt;setText(text);</pre>
<p>The <tt>ok</tt> variable is set to true if the user clicks <b>OK</b>; otherwise it is set to false.</p>
<p align="center"><img src="images/inputdialogs.png" alt="Input Dialogs" /></p><p>The <a href="dialogs-standarddialogs.html">Standard Dialogs</a> example shows how to use QInputDialog as well as other built-in Qt dialogs.</p>
<p>See also <a href="qmessagebox.html">QMessageBox</a> and <a href="dialogs-standarddialogs.html">Standard Dialogs Example</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="getDouble"></a>double QInputDialog::getDouble ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i>, const <a href="qstring.html">QString</a> &amp; <i>label</i>, double <i>value</i> = 0, double <i>minValue</i> = -2147483647, double <i>maxValue</i> = 2147483647, int <i>decimals</i> = 1, bool * <i>ok</i> = 0, <a href="qt.html#WindowType-enum">Qt::WindowFlags</a> <i>f</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Static convenience function to get a floating point number from the user. <i>title</i> is the text which is displayed in the title bar of the dialog. <i>label</i> is the text which is shown to the user (it should say what should be entered). <i>value</i> is the default floating point number that the line edit will be set to. <i>minValue</i> and <i>maxValue</i> are the minimum and maximum values the user may choose, and <i>decimals</i> is the maximum number of decimal places the number may have.</p>
<p>If <i>ok</i> is non-null, *<i>ok</i> will be set to true if the user pressed <b>OK</b> and to false if the user pressed <b>Cancel</b>. The dialog's parent is <i>parent</i>. The dialog will be modal and uses the widget flags <i>f</i>.</p>
<p>This function returns the floating point number which has been entered by the user.</p>
<p>Use this static function like this:</p>
<pre>     bool ok;
     double d = QInputDialog::getDouble(this, tr(&quot;QInputDialog::getDouble()&quot;),
                                        tr(&quot;Amount:&quot;), 37.56, -10000, 10000, 2, &amp;ok);
     if (ok)
         doubleLabel-&gt;setText(QString(&quot;$%1&quot;).arg(d));</pre>
<p>See also <a href="qinputdialog.html#getText">getText</a>(), <a href="qinputdialog.html#getInteger">getInteger</a>(), and <a href="qinputdialog.html#getItem">getItem</a>().</p>
<h3 class="fn"><a name="getInteger"></a>int QInputDialog::getInteger ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i>, const <a href="qstring.html">QString</a> &amp; <i>label</i>, int <i>value</i> = 0, int <i>minValue</i> = -2147483647, int <i>maxValue</i> = 2147483647, int <i>step</i> = 1, bool * <i>ok</i> = 0, <a href="qt.html#WindowType-enum">Qt::WindowFlags</a> <i>f</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Static convenience function to get an integer input from the user. <i>title</i> is the text which is displayed in the title bar of the dialog. <i>label</i> is the text which is shown to the user (it should say what should be entered). <i>value</i> is the default integer which the spinbox will be set to. <i>minValue</i> and <i>maxValue</i> are the minimum and maximum values the user may choose, and <i>step</i> is the amount by which the values change as the user presses the arrow buttons to increment or decrement the value.</p>
<p>If <i>ok</i> is non-null *<i>ok</i> will be set to true if the user pressed <b>OK</b> and to false if the user pressed <b>Cancel</b>. The dialog's parent is <i>parent</i>. The dialog will be modal and uses the widget flags <i>f</i>.</p>
<p>This function returns the integer which has been entered by the user.</p>
<p>Use this static function like this:</p>
<pre>     bool ok;
     int i = QInputDialog::getInteger(this, tr(&quot;QInputDialog::getInteger()&quot;),
                                      tr(&quot;Percentage:&quot;), 25, 0, 100, 1, &amp;ok);
     if (ok)
         integerLabel-&gt;setText(tr(&quot;%1%&quot;).arg(i));</pre>
<p>See also <a href="qinputdialog.html#getText">getText</a>(), <a href="qinputdialog.html#getDouble">getDouble</a>(), and <a href="qinputdialog.html#getItem">getItem</a>().</p>
<h3 class="fn"><a name="getItem"></a><a href="qstring.html">QString</a> QInputDialog::getItem ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i>, const <a href="qstring.html">QString</a> &amp; <i>label</i>, const <a href="qstringlist.html">QStringList</a> &amp; <i>list</i>, int <i>current</i> = 0, bool <i>editable</i> = true, bool * <i>ok</i> = 0, <a href="qt.html#WindowType-enum">Qt::WindowFlags</a> <i>f</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Static convenience function to let the user select an item from a string list. <i>title</i> is the text which is displayed in the title bar of the dialog. <i>label</i> is the text which is shown to the user (it should say what should be entered). <i>list</i> is the string list which is inserted into the combobox, and <i>current</i> is the number of the item which should be the current item. If <i>editable</i> is true the user can enter their own text; if <i>editable</i> is false the user may only select one of the existing items.</p>
<p>If <i>ok</i> is non-null <i>*a</i> ok will be set to true if the user pressed <b>OK</b> and to false if the user pressed <b>Cancel</b>. The dialog's parent is <i>parent</i>. The dialog will be modal and uses the widget flags <i>f</i>.</p>
<p>This function returns the text of the current item, or if <i>editable</i> is true, the current text of the combobox.</p>
<p>Use this static function like this:</p>
<pre>     QStringList items;
     items &lt;&lt; tr(&quot;Spring&quot;) &lt;&lt; tr(&quot;Summer&quot;) &lt;&lt; tr(&quot;Fall&quot;) &lt;&lt; tr(&quot;Winter&quot;);

     bool ok;
     QString item = QInputDialog::getItem(this, tr(&quot;QInputDialog::getItem()&quot;),
                                          tr(&quot;Season:&quot;), items, 0, false, &amp;ok);
     if (ok &amp;&amp; !item.isEmpty())
         itemLabel-&gt;setText(item);</pre>
<p>See also <a href="qinputdialog.html#getText">getText</a>(), <a href="qinputdialog.html#getInteger">getInteger</a>(), and <a href="qinputdialog.html#getDouble">getDouble</a>().</p>
<h3 class="fn"><a name="getText"></a><a href="qstring.html">QString</a> QInputDialog::getText ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i>, const <a href="qstring.html">QString</a> &amp; <i>label</i>, <a href="qlineedit.html#EchoMode-enum">QLineEdit::EchoMode</a> <i>mode</i> = QLineEdit::Normal, const <a href="qstring.html">QString</a> &amp; <i>text</i> = QString(), bool * <i>ok</i> = 0, <a href="qt.html#WindowType-enum">Qt::WindowFlags</a> <i>f</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Static convenience function to get a string from the user. <i>title</i> is the text which is displayed in the title bar of the dialog. <i>label</i> is the text which is shown to the user (it should say what should be entered). <i>text</i> is the default text which is placed in the line edit. The <i>mode</i> is the echo mode the line edit will use. If <i>ok</i> is non-null <i>*a</i> ok will be set to true if the user pressed <b>OK</b> and to false if the user pressed <b>Cancel</b>. The dialog's parent is <i>parent</i>. The dialog will be modal and uses the widget flags <i>f</i>.</p>
<p>This function returns the text which has been entered in the line edit. It will not return an empty string.</p>
<p>Use this static function like this:</p>
<pre>     bool ok;
     QString text = QInputDialog::getText(this, tr(&quot;QInputDialog::getText()&quot;),
                                          tr(&quot;User name:&quot;), QLineEdit::Normal,
                                          QDir::home().dirName(), &amp;ok);
     if (ok &amp;&amp; !text.isEmpty())
         textLabel-&gt;setText(text);</pre>
<p>See also <a href="qinputdialog.html#getInteger">getInteger</a>(), <a href="qinputdialog.html#getDouble">getDouble</a>(), and <a href="qinputdialog.html#getItem">getItem</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
